package reittiopas;

import javax.microedition.io.*;
import java.io.*;

/**
 *
 * @author Jaakko
 */
public class RouteService {



   public String getViaHttpConnection(String url) {  //muuta privaatiksi
         HttpConnection c = null;
         InputStream is = null;
              StringBuffer str = new StringBuffer();

              try {
                  c = (HttpConnection)Connector.open(url);



                // Getting the InputStream will open the connection
                // and read the HTTP headers. They are stored until
                // requested.
                is = c.openInputStream();

                // Get the length and process the data
             int len = (int)c.getLength();
             int ch;
             while ((ch = is.read()) != -1) {
                 str.append((char)ch);
             }
          if (is != null)
              is.close();
          if (c != null)
              c.close();
          } catch (IOException e) {
              System.out.print(e);
          }
     return str.toString();

   }

}
